package com.project.mapper;

import com.github.pagehelper.PageInfo;
import com.project.bean.MessageBean;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface IMessageMapper {
    /**
     * 添加通讯录信息
     * @param message
     */
    @Insert("insert into t_message(m_name,m_phone,m_job) value(#{name},#{phone},#{job})")
    public void add(MessageBean message);

    /**
     * 按id删除通讯录信息
     * @param id
     */
    @Delete("delete from t_message where pk_messageId=#{id}")
    public void del(int id);

    /**
     * 按ID修改电话
     * @param id
     * @param phone
     */
    @Update("update t_message set m_phone=#{phone} where pk_messageId=#{id}")
    public void update(@Param("id") int id,
                       @Param("phone") String phone);

    /**
     * 按名字动态分页查询
     * @param name
     * @return
     */
    public List<MessageBean> findByItem(String name);

    /**
     * 按id查找通讯录信息
     * @param id
     * @return
     */
    @Select("select * from t_message where pk_messageId=#{id}")
    @ResultMap("msMap")
    public MessageBean findById(int id);
}
